import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;


public class Sendmail
{
	public static void sendmail() throws AddressException
	{
		try {
		    Properties		props	    = new Properties();
		    props.setProperty("mail.from", "joel.courtois@epita.fr");
		    props.put("mail.smtp.host", "smtp.orange.fr");
		    Session		session	    = Session.getInstance(props);
	 
		    Message		message	    = new MimeMessage(session);
		    InternetAddress	recipient   = new InternetAddress("violetvisions@hotmail.fr"); 
		    message.setRecipient(Message.RecipientType.TO, recipient);
		    message.setSubject("[SRS2013] Information importante");
		    message.setText("Seb n'aura pas son diplome");
	 
		    Transport.send(message);
		    System.out.println("Done");
		}
		catch(NoSuchProviderException e) {
		    System.err.println("Pas de transport disponible pour ce protocole");
		    System.err.println(e);
		}
		catch(AddressException e) {
		    System.err.println("Adresse invalide");
		    System.err.println(e);
		}
		catch(MessagingException e) {
		    System.err.println("Erreur dans le message");
		    System.err.println(e);
		}
		
	}
}
